
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 08/30/2013 08:19:05
-- Generated from EDMX file: C:\Users\cbahr.CHCW\Desktop\MyProjects\WoTStats.Model\WoTStatsModel.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [DB_63119_wotstats];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------


-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Players'
CREATE TABLE [dbo].[Players] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [AccountDBID] nvarchar(max)  NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [ClanName] nvarchar(max)  NOT NULL,
    [ClanDBID] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'BattleResults'
CREATE TABLE [dbo].[BattleResults] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [PlayerId] int  NOT NULL,
    [BattleID] nvarchar(max)  NOT NULL,
    [BattleDate] datetime  NOT NULL,
    [MapName] nvarchar(max)  NOT NULL,
    [BattleType] int  NOT NULL,
    [Duration] int  NOT NULL,
    [FinishReason] int  NOT NULL,
    [WinningTeam] int  NOT NULL,
    [EquipementCostGold] int  NOT NULL,
    [EquipmentCostCredits] int  NOT NULL,
    [AutoLoadCostGold] int  NOT NULL,
    [AutoLoadCostCredits] int  NOT NULL,
    [AutoRepairCost] int  NOT NULL,
    [CapturePoints] int  NOT NULL,
    [Credits] int  NOT NULL,
    [Country] int  NOT NULL,
    [CreditPenalty] int  NOT NULL,
    [DailyXPFactor] int  NOT NULL,
    [DamageAssisted] int  NOT NULL,
    [DamageDealt] int  NOT NULL,
    [DamageReceived] int  NOT NULL,
    [Damaged] int  NOT NULL,
    [DroppedCapturePoints] int  NOT NULL,
    [EventCredits] int  NOT NULL,
    [EventFreeXP] int  NOT NULL,
    [EventGold] int  NOT NULL,
    [EventTMenXP] int  NOT NULL,
    [EventXP] int  NOT NULL,
    [FreeXP] int  NOT NULL,
    [Gold] int  NOT NULL,
    [HEHits] int  NOT NULL,
    [Health] int  NOT NULL,
    [Hits] int  NOT NULL,
    [IsPremium] bit  NOT NULL,
    [IsTeamKiller] bit  NOT NULL,
    [Mileage] int  NOT NULL,
    [Pierced] int  NOT NULL,
    [RepairCost] int  NOT NULL,
    [Shots] int  NOT NULL,
    [ShotsReceived] int  NOT NULL,
    [Spotted] int  NOT NULL,
    [TankID] int  NOT NULL,
    [TankName] nvarchar(max)  NOT NULL,
    [TeamDamageDealt] int  NOT NULL,
    [Team] int  NOT NULL,
    [TeamKills] int  NOT NULL,
    [TMenXP] int  NOT NULL,
    [Won] bit  NOT NULL,
    [XP] int  NOT NULL,
    [XPPenalty] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Players'
ALTER TABLE [dbo].[Players]
ADD CONSTRAINT [PK_Players]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'BattleResults'
ALTER TABLE [dbo].[BattleResults]
ADD CONSTRAINT [PK_BattleResults]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [PlayerId] in table 'BattleResults'
ALTER TABLE [dbo].[BattleResults]
ADD CONSTRAINT [FK_PlayerBattleResult]
    FOREIGN KEY ([PlayerId])
    REFERENCES [dbo].[Players]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PlayerBattleResult'
CREATE INDEX [IX_FK_PlayerBattleResult]
ON [dbo].[BattleResults]
    ([PlayerId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------